using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using Scintilla.Configuration.SciTE;
using Scintilla.Configuration;

namespace Ltf.MonitorLizard.Forms
{
	public partial class ChangeRegionEditor : Form
	{
		private DialogResult dialogResult = DialogResult.Cancel;
		private string yourLines = string.Empty;
		private string theirLines = string.Empty;

		public ChangeRegionEditor(string yourLines, string theirLines, string extention)
		{
			InitializeComponent();

			this.yourLines = yourLines;
			this.theirLines = theirLines;

			FileInfo globalConfigFile = new FileInfo(@"Configuration\global.properties");
			if (globalConfigFile.Exists)
			{
				SciTEProperties properties = new SciTEProperties();
				properties.Load(globalConfigFile);
				scintillaExtra1.Configuration = new ScintillaConfig(properties);
			}

			List<string> fonts = new List<string>();
			int i = 0;
			foreach (KeyValuePair<int, ILexerStyle> kvp in scintillaExtra1.Configuration.Lexers[3].Styles)
			{
				ILexerStyle ls = kvp.Value;
				if (ls.FontName == null)
				{
					ls.FontSize = 8;
					ls.FontName = "Lucida Console";
					i++;
				}
				
			}
			scintillaExtra1.Configuration.TabSize = 3;
			scintillaExtra1.ConfigurationLanguage = extention.Replace(".", "");

		}

		public string EditLines
		{
			get
			{
				return scintillaExtra1.Text;
			}
			set
			{
				scintillaExtra1.Text = value;
			}
		}

		public new DialogResult ShowDialog()
		{
			base.ShowDialog();

			return dialogResult;
		}

		private void btnOkay_Click(object sender, EventArgs e)
		{
			dialogResult = DialogResult.OK;
			Close();
		}

		private void bntCancel_Click(object sender, EventArgs e)
		{
			dialogResult = DialogResult.Cancel;
			Close();
		}

		private void tsbTheirLines_Click(object sender, EventArgs e)
		{
			int pos = scintillaExtra1.CurrentPos;
			scintillaExtra1.InsertText(pos, theirLines);
		}

		private void tsbYourLines_Click(object sender, EventArgs e)
		{
			int pos = scintillaExtra1.CurrentPos;
			scintillaExtra1.InsertText(pos, yourLines);
		}

		private void tsbCut_Click(object sender, EventArgs e)
		{
			scintillaExtra1.Cut();
		}

		private void tsbCopy_Click(object sender, EventArgs e)
		{
			scintillaExtra1.Copy();
		}

		private void tsbPaste_Click(object sender, EventArgs e)
		{
			scintillaExtra1.Paste();
		}
	}
}